package com.quirka.logica;

import java.awt.image.BufferedImage;

public class CalcularVectorHistograma
{

    public static int[] calcular(BufferedImage buffImagenGris){

       int contarEscalaGrises[]=new int[256];
       int pix[] = new int[1];
       int n = buffImagenGris.getWidth();
       int m = buffImagenGris.getHeight();
     
       for(int i = 0; i < 256; i++){
           contarEscalaGrises[i]=0;
       }
      
        for (int fila = 0; fila < n; fila++) 
        {        
          for (int col = 0; col < m; col++) 
           {          
              buffImagenGris.getRaster().getPixel(fila, col, pix);
              int indice=pix[0];
              if(indice<256)
                  contarEscalaGrises[indice]++;
                         
           }
        }   
        return contarEscalaGrises;
    }
}
